package bean.loader;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import dao.DAOFactory;
import dao.oracle.JenisKeretaApiDao;

import bean.KeretaApiBean;

public class KeretaApiLoader implements BeanLoader<KeretaApiBean>{

	@Override
	public List<KeretaApiBean> loadList(ResultSet rs) throws SQLException {
		List<KeretaApiBean> list = new ArrayList<KeretaApiBean>();
		while(rs.next())
			list.add(loadSingle(rs));
		return list;
	}

	@Override
	public KeretaApiBean loadSingle(ResultSet rs) throws SQLException {
		KeretaApiBean bean = new KeretaApiBean();
		JenisKeretaApiDao jenisKADao = DAOFactory.createJenisKeretaApiDao();
		bean.setJenisKeretaApi(jenisKADao.getJenisLokoWhereIdLoko(rs.getString("ID_JENIS_KA")));
		bean.setNoKertaApi(rs.getInt("NO_KERETA_API"));
		bean.setAvailable(rs.getBoolean("AVAILABLE"));
		return bean;
	}

	@Override
	public PreparedStatement loadParameters(PreparedStatement ps,
			KeretaApiBean bean) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

}
